package com.njtech.smartuniversity.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.njtech.smartuniversity.bean.InformBean;
import com.njtech.smartuniversity.bean.InformBeanExample;
import com.njtech.smartuniversity.dao.InformBeanMapper;
import com.njtech.smartuniversity.service.InformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by ritchie on 6/25/18
 */

@Service
public class InformServiceImpl implements InformService {

    @Autowired
    InformBeanMapper mInformBeanMapper;

    @Override
    public int update(InformBean areaBean) {
        Integer id = areaBean.getId();
        return  mInformBeanMapper.update(areaBean);
    }

    @Override
    public List<InformBean> getAllUsers() {
        InformBeanExample areaBeanExample = new InformBeanExample();
        InformBeanExample.Criteria criteria =areaBeanExample.createCriteria() ;
        criteria.andIdIsNotNull();
        return mInformBeanMapper.selectByExample(areaBeanExample);
    }

    @Override
    public PageInfo<InformBean> getAreasByPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<InformBean> list = getAllUsers();//这个查询会分页
        return new PageInfo<>(list);
    }


    @Override
    public boolean deleteById(int id) {
        int result = mInformBeanMapper.delete(id);
        return result != 0;
    }

    @Override
    public int addInform(InformBean AreaBean) {
        return mInformBeanMapper.insert(AreaBean);
    }


    @Override
    public List<InformBean> selectlist() {
        return mInformBeanMapper.selectlist();
    }



}
